home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7841 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: I need some help with a homework
  5. Date: Mon, 19 Feb 1996 18:56:52 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4gah4i$907@news.halcyon.com>
  8. References: <4g8o4f$m93@ixnews7.ix.netcom.com>
  9. NNTP-Posting-Host: blv-pm12-ip19.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Comments prefaced by <=======
  13.  
  14.                 --Norm 
  15.  
  16. lewkbj@ix.netcom.com (leonel wizel ) wrote:
  17.  
  18. >....
  19.  
  20. >The program suppose to
  21.  
  22. >Enter hours worked (-1 to end): 39
  23. >enter hourly rate of the worker ($00:00): 10.00
  24. >salary is $390.00
  25.  
  26. >Enter hours worked (-1 to end): 40
  27. >enter hourly rate of the worker ($00:00): 10.00
  28. >salary is $400.00
  29.  
  30. >...
  31. >the following program I wrote but, only gives me one amout which is
  32. >$390.00, it supposse to give me the second amount which is 400.00
  33. >but, it keeps repeating the same figure which is 390.00
  34.  
  35.  
  36. >#include <iostream.h>
  37. >#include <iomanip.h>
  38.  
  39. >main()
  40. >{
  41. >//initialization phase
  42.  
  43. >float hour_rate, salary, hours_worked;
  44.  
  45.  
  46. >cout << "Enter hours worked (-1 to end): ";
  47. >cin >> hours_worked;
  48.  
  49. >    if (hours_worked != 1)                   <=========  -1?
  50. >    {
  51. >    cout << "Enter hourly rate of the  worker ($00.00): ";
  52. >    cin >> hour_rate;
  53. >    }
  54.  
  55. >//processing phase
  56. >    
  57. >    while (hours_worked != -1)
  58. >    {
  59. >    if (hours_worked > 40)
  60. >        {
  61. >        salary = hours_worked * hour_rate + 
  62. >                     (hour_worked * 1.5 * hour_rate);   <=========(hours_worked-40)*1.5?
  63. >        }
  64. >    else
  65. >        salary = hours_worked * hour_rate;
  66.  
  67. >    cout << "The salary for the employee is: \n"
  68. >         << setiosflags(ios::fixed | ios::showpoint)
  69. >         << setprecision(2) << salary << endl;
  70.  
  71. >    cout << endl;
  72.  
  73. >    cout <<"Enter hours worked (-1 to end): ";
  74. >    cin >> hour_rate;                   <========= hours_worked !!!
  75.  
  76. >    if (hours_worked != -1)
  77. >        {
  78. >        cout << "Enter hourly rate of the worker ($00.00): ";
  79. >        cin >> hour_rate;
  80. >        }
  81. >    }
  82.  
  83. >//termination phase
  84.  
  85. >if (hours_worked == -1)
  86. >    {
  87. >    cout << endl;
  88. >    cout << "no hours were entered";
  89. >    }
  90.  
  91. >return 0;
  92. >}
  93.  
  94. >...
  95. >Thank you.
  96.  
  97.  
  98.  
  99.  
  100.